<?php

if (!defined('PUBLIC_HTML'))
{
	exit;
}

$page_title = 'Menu overview';

if ($user->is_admin)
{
	$tpl->zone("ADMIN", array());
}

if ($database->sqlCount(TABLE_MENU) > 0)
{
	$get_menu	=	"
					SELECT		*
					FROM		" . TABLE_MENU . "
					ORDER BY	men_id
					ASC
					";
	$database->query($get_menu);
	foreach ($database->resultSet() as $row_menu)
	{
		switch ($row_menu['men_target'])
		{
			case TARGET_SELF:
				$menu_target = 'Same Tab';
				break;
				
			case TARGET_BLANK:
				$menu_target = 'New Tab';
				break;
				
			case TARGET_PARENT:
				$menu_target = 'Parent Frame';
				break;
			
			case TARGET_TOP:
				$menu_target = 'Full Window';
				break;
				
			default:
				$menu_target = 'Undefined';
				break;
		}
		$tpl->zone('menu', array(
			'ID1'		=> (int)	$row_menu['men_id'],
			'ID2'		=> (int)	$row_menu['men_id'],
			'TITLE'		=> (string) $row_menu['men_title'],
			'TARGET'	=> (string)	$menu_target,
			'VIEW'		=> (string) $row_menu['men_link'],
			'EDIT'		=> (string) 'cms.php?p=menu&act=edit&id=' . intval($row_menu['men_id']),
			'DELETE'	=> (string) 'cms.php?p=menu&act=delete&id=' . intval($row_menu['men_id'])
		));
	}
}
else
{
	$tpl->zone('noresults', array(
		'NO_RESULTS_MSG'	=> 'No results have been found!'
	));
}

?>